﻿using System.Collections.Generic;

namespace TopHero
{
    public class EntityManager : Singleton<EntityManager>
    {
        private Dictionary<int, BaseEntity> _entityMap = new Dictionary<int, BaseEntity>();

        internal void RegisterEntity(BaseEntity newEntity)
        {
            Debug.Assert(!_entityMap.ContainsKey(newEntity.ID()));
            _entityMap.Add(newEntity.ID(), newEntity);
        }

        internal BaseEntity GetEntityFromID(int id)
        {
            Debug.Assert(_entityMap.ContainsKey(id));
            return _entityMap[id];
        }

        internal void RemoveEntity(BaseEntity entity)
        {
            Debug.Assert(_entityMap.ContainsKey(entity.ID()));
            _entityMap.Remove(entity.ID());
        }

        internal void Reset()
        {
            _entityMap.Clear();
        }
    }
}